﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DCSLibrary;
using Utils.DatabaseUtils;
using Utils.DC.Web.UI;

public partial class Admin_Module_cap_nhat_banner_trai : System.Web.UI.UserControl
{
    PropertiesUI objPro = new PropertiesUI();
    DataSet ds;
    protected void Page_Load(object sender, EventArgs e)
    {
        ds = objPro.GetByPropertyTypeName("Component");
        if (!IsPostBack)
        {
            if (TableLib.HasData(ds))
            {
                DataTable dt = TableLib.CreateTable(ds.Tables[0], "PropertyName = 'LeftBanner'");
                if (dt != null && dt.Rows.Count > 0)
                {
                    btnUpdate.CommandArgument = dt.Rows[0]["PropertyID"].ToString();
                    txtLink.Text = dt.Rows[0]["PropertyValue"].ToString().Trim();
                    return;
                }
            }
            btnUpdate.CommandArgument = "";
        }
    }

    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        Button button = (Button)sender;
        int result = -1;
        //Neu la update
        if (button.CommandArgument.Trim() != "")
        {
            result = objPro.Update(Convert.ToInt32(button.CommandArgument.Trim()), "Component", "LeftBanner", txtLink.Text, true, true);
        }
        else
        {
            result = objPro.Add("Component", "LeftBanner", txtLink.Text, true, true);
        }

        if (result > 0)
        {
            //Response.Write(messageBox.Alert(MessageBox.MESSAGE_ADD_SUCCESSFULLY));
            lblMessage.Text = MessageBox.MESSAGE_UPDATE_SUCCESSFULLY;
        }
        else
        {
            //Response.Write(messageBox.Alert(MessageBox.MESSAGE_ADD_NOT_SUCCESSFULLY));
            lblMessage.Text = MessageBox.MESSAGE_UPDATE_NOT_SUCCESSFULLY;
        }
    }
}
